package com.yc.healthy.controller;


import com.yc.healthy.entity.Article;
import com.yc.healthy.entity.Cuisine;
import com.yc.healthy.entity.Result;
import com.yc.healthy.mapper.ArticleMapper;
import com.yc.healthy.mapper.CuisineMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyl
 * @since 2023-03-08
 */
@Controller
@RequestMapping("/healthy/article")
public class ArticleController {

    @Resource
    ArticleMapper articleMapper;

    @PostMapping("querybytype")
    @ResponseBody
    public Result queryArticle(){
        List<Article> articles = articleMapper.SelectArticle();
        if (articles.isEmpty()){
            return new Result(0,"查无数据",null);
        }else {
            return new Result(1,"查询成功",articles);
        }

    }

    @PostMapping("querybyAid")
    @ResponseBody
    public Result queryByid( int id){
        Article article = articleMapper.selectById(id);
        if ("".equals(article) || article == null){
            return new Result(0,"查无数据",null);
        }else {
            return new Result(1,"查询成功",article);
        }
    }

}

